import java.util.Scanner;
import java.util.Arrays;
public class text2 {
    /*给你一个按照非递减顺序排列的整数数组 nums，和一个目标值 target。请你找出给定目标值在数组中的开始位置和结束位置。
    如果数组中不存在目标值 target，返回 [-1, -1]。
    你必须设计并实现时间复杂度为 O(log n) 的算法解决此问题。*/
    public static int[]seekaddress(int[]nums,int target) {
        int n = nums.length;
        int[] index = {-1, -1};
        int left = 0, right = n - 1;
        if (nums == null || nums.length == 0) return index;//空数组直接返回-1，-1
        //判断左边界，从>=target开始，left逐渐靠近左target
        while (left <= right) {
            int mid = left + (right-left) / 2;
            if (nums[mid] >= target) {
                right = mid - 1;
            } else  {
                left = mid + 1;
            }
        }
        if(left<n&&nums[left]==target){
            index[0] = left;
        }
        else return index;
        right=n-1;//重置右指针
        //判断右边界，从<=target开始，right逐渐靠近右target
        while (left <= right) {
            int mid = left + (right-left) / 2;
            if (nums[mid] <= target) {
                left = mid +1;
            } else {
                right = mid - 1;
            }
            index[1] = right;
        }
        return index;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int target = sc.nextInt();
        int[]nums=new int[n];
        for(int i=0;i<n;i++){
            nums[i]=sc.nextInt();
        }
        int[]arr=new int[2];
        arr=seekaddress(nums,target);
        System.out.println(Arrays.toString(arr));
        sc.close();
    }
}
